<?php
// @formatter:off
/**
 * @file pager.php
 * @author Alejandro Dario Simi
 * @date $Date: 2013-05-19 06:39:24 +0000 (Sun, 19 May 2013) $
 *
 * $Id: pager.php 65 2013-05-19 06:39:24Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/tags/wcomix-1.0-BETA1/themes/mdefault/controlers/generics/pager.php $
 */
// @formatter:on

/**
 * Sets parameters for template /generics/pager.html
 *
 * @param string $link URL to be prepend on each page link.
 * @param integer $pages Amount of pages.
 * @param integer $page Current page (first page is one).
 */
function wcSetPager($link, $pages, $page = 1) {
	if($pages > 1) {
		global $wcThemeMobileDefault;
		global $wcThemeAssigns;

		if($page != 1) {
			$wcThemeMobileDefault->addBarIcons(50, "PAGER_FIRST", "document.location.href='{$link}&page=1'", "{$wcThemeMobileDefault->uri()}/icons/move-first-icon.png");

			$aux = $page - 1;
			$wcThemeMobileDefault->addBarIcons(51, "PAGER_PREVIOUS", "document.location.href='{$link}&page=".($aux < 1 ? 1 : $aux)."'", "{$wcThemeMobileDefault->uri()}/icons/move-previous-icon.png");
		}

		if($page != $pages) {
			$aux = $page + 1;
			$wcThemeMobileDefault->addBarIcons(53, "PAGER_PREVIOUS", "document.location.href='{$link}&page=".($aux > $pages ? $pages : $aux)."'", "{$wcThemeMobileDefault->uri()}/icons/move-next-icon.png");

			$wcThemeMobileDefault->addBarIcons(54, "PAGER_LAST", "document.location.href='{$link}&page={$pages}'", "{$wcThemeMobileDefault->uri()}/icons/move-last-icon.png");
		}

		$wcThemeAssigns["PAGER-SHOW"] = true;
		$wcThemeAssigns["PAGER-CURRENT"] = $page;
		$wcThemeAssigns["PAGER-COUNT"] = $pages;
		$wcThemeAssigns["PAGER-OPENLINK"] = "{$link}&page=";
	}
}
?>